<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include2923 :: header('综合分析比对行上详情列表')"/>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
<!--                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit-->
<!--                        lay-filter="infoAnaViewDtl-query">-->
<!--                    <i class="layui-icon layui-icon-search"></i>-->
<!--                    查询-->
<!--                </button>-->
<!--                <button type="reset" class="pear-btn pear-btn-md">-->
<!--                    <i class="layui-icon layui-icon-refresh"></i>-->
<!--                    重置-->
<!--                </button>-->
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="infoAnaViewDtl-table" lay-filter="infoAnaViewDtl-table"></table>
    </div>
</div>
</body>

<script type="text/html" id="infoAnaViewDtl-toolbar">

</script>

<script type="text/html" id="infoAnaViewDtl-bar">

</script>


<script type="text/html" id="infoAnaViewDtl-type">
    {{#if (d.dataState == '0') { }}
    <span class="layui-badge layui-bg-orange">开启</span>
    {{# }else if(d.dataState == '-1'){ }}
    <span class="layui-badge layui-bg-blue">关闭</span>
    {{# } }}
</script>

<th:block th:include="include2923 :: footer"/>
<script th:inline="javascript" type="text/javascript">
    layui.use(['table', 'form', 'jquery'], function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;

        var id = [[${id}]];

        var MODULE_PATH = rootPath + "/InfoProjectbudgetController/";
        var cols = [
            [
                // {type: 'checkbox'},
                //
                // {title: '主键ID', field: 'id', align: 'center'},

                // {title: '主表id', field: 'mainid', align: 'center'},

                {title: '费用名称', field: 'proname', align: 'center', width: 200},
                {title: '可研阶段费用', field: 'kyresult', align: 'center', width: 180},
                // {title: '可研与初设差额', field: 'kycscha', align: 'center', width: 180},
                {
                    title: '可研与初设差额', field: 'kycscha', align: 'center', width: 180, templet: function (res) {
                        if (res.kycscha == 0) {
                            return '0';
                        } else if (!res.kycscha) {
                            return '/';
                        } else {
                            return '<div style="background-color:#ff7777; width: 100%; height: 100%;"><a class=""style="color:#fff">'+res.kycscha+'</a></div>';
                        }
                    }
                },
                {title: '初设阶段费用', field: 'csresult', align: 'center', width: 180},
                // {title: '初设与结算差值', field: 'csjscha', align: 'center', width: 180},
                {
                    title: '初设阶段费用', field: 'csjscha', align: 'center', width: 180, templet: function (res) {
                        if (res.csjscha == 0) {
                            return '0';
                        } else if (!res.csjscha) {
                            return '/';
                        } else {
                            return '<div style="background-color:#ff7777; width: 100%; height: 100%;"><a class=""style="color:#fff">'+res.csjscha+'</a></div>';
                        }
                    }
                },
                {title: '结算阶段费用', field: 'jsresult', align: 'center', width: 180},
                // {title: '可研与结算差值', field: 'kyjscha', align: 'center', width: 180},
                {
                    title: '可研与结算差值', field: 'kyjscha', align: 'center', width: 180, templet: function (res) {
                        if (res.kyjscha == 0) {
                            return '0';
                        } else if (!res.kyjscha) {
                            return '/';
                        } else {
                            return '<div style="background-color:#ff7777; width: 100%; height: 100%;"><a class=""style="color:#fff">'+res.kyjscha+'</a></div>';
                        }
                    }
                },
                //
                // {title: '操作', toolbar: '#infoAnaViewDtl-bar', align: 'center'}
            ]
        ]

        //table表单列表
        table.render({
            elem: '#infoAnaViewDtl-table',
            url: MODULE_PATH + 'viewdtlList/'+id,
            page: true,
            method: 'get',
            cols: cols,
            skin: 'line',
            toolbar: '#infoAnaViewDtl-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }],
            height:500,
            limit:80
        });

        //table图标事件绑定
        table.on('tool(infoAnaViewDtl-table)', function (obj) {
            if (obj.event === 'remove') {
                window.remove(obj);
            } else if (obj.event === 'edit') {
                window.edit(obj);
            }
        });

        //table工具栏绑定
        table.on('toolbar(infoAnaViewDtl-table)', function (obj) {
            if (obj.event === 'add') {
                window.add();
            } else if (obj.event === 'refresh') {
                window.refresh();
            } else if (obj.event === 'batchRemove') {
                window.batchRemove(obj);
            }
        });

        //查询按钮绑定
        form.on('submit(infoAnaViewDtl-query)', function (data) {
            table.reload('infoAnaViewDtl-table', {where: data.field})
            return false;
        });


        //添加
        window.add = function () {
            layer.open({
                type: 2,
                title: '新增',
                shade: 0.1,
                area: ['500px', '500px'],
                content: MODULE_PATH + 'add'
            });
        }
        //修改
        window.edit = function (obj) {
            layer.open({
                type: 2,
                title: '修改',
                shade: 0.1,
                area: ['500px', '500px'],
                content: MODULE_PATH + 'edit/' + obj.data['id']
            });
        }
        //删除
        window.remove = function (obj) {
            layer.confirm('确定要删除该数据', {icon: 3, title: '提示'}, function (index) {
                layer.close(index);
                var loading = layer.load();
                $.ajax({
                    url: MODULE_PATH + "remove?ids=" + obj.data['id'],
                    dataType: 'json',
                    type: 'delete',
                    success: function (result) {
                        layer.close(loading);
                        if (result.code == 200) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                obj.del();
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                })
            });
        }

        //批量删除
        window.batchRemove = function (obj) {
            var data = table.checkStatus(obj.config.id).data;
            if (data.length === 0) {
                layer.msg("未选中数据", {icon: 3, time: 1000});
                return false;
            }
            var ids = "";
            for (var i = 0; i < data.length; i++) {
                ids += data[i].id + ",";
            }
            ids = ids.substr(0, ids.length - 1);
            layer.confirm('确定要删除这些数据', {icon: 3, title: '提示'}, function (index) {
                layer.close(index);
                var loading = layer.load();
                $.ajax({
                    url: MODULE_PATH + "remove?ids=" + ids,
                    dataType: 'json',
                    type: 'delete',
                    success: function (result) {
                        layer.close(loading);
                        if (result.code == 200) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                table.reload('infoAnaViewDtl-table');
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                })
            });
        }
        //刷新按钮
        window.refresh = function () {
            table.reload('infoAnaViewDtl-table');
        }
    })
</script>
</html>